package com.team5.controller;

import java.util.List;

import com.github.pagehelper.PageInfo;
import com.team5.entity.ChinaIndex;
import com.team5.response.Code;
import com.team5.response.Result;
import com.team5.service.ChinaIndexService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RequestMapping("/chinaIndex")
@RestController
public class ChinaIndexController {
    @Autowired
    private ChinaIndexService service;
    @RequestMapping("/findById")
    public Result findByID(int id){
        ChinaIndex chinaIndex = service.findById(id);
        return new Result(Code.SELECT_OK,chinaIndex);
    }
    @RequestMapping("/findAll")
    public Result findAll(){
        ChinaIndex[] chinaIndices = service.findAll();
        return new Result(Code.SELECT_OK,chinaIndices);
    }
    @RequestMapping("/findByPage")
    public Result findByPage(@RequestParam(value = "pageNum",defaultValue = "1")int pageNum,
                             @RequestParam(value = "pageSize",defaultValue = "5")int pageSize ){
        PageInfo<ChinaIndex> chinaIndexPageInfo=service.findByPage(pageNum,pageSize);
        return new Result(Code.SELECT_OK,chinaIndexPageInfo);
    }
}
